<template>
  <div id="tpl" v-if="info.id">
    <mt-header title="资讯详情">
      <router-link to="/news/newslist" slot="left">
        <mt-button icon="back">返回</mt-button>
      </router-link>
    </mt-header>
    <div class="title">
      <h4>{{info.title}}</h4>
      <p><time>{{info.add_time | dateFmt('YYYY-MM-DD')}}</time>&nbsp;&nbsp;<span>{{info.click}}次浏览</span></p>
    </div>
    <div class="content" v-html="info.content"></div>

    <!-- 评论组件 -->
    <comment :id="info.id"></comment>
  </div>
</template>

<script>
  import common from '../../kits/common.js';

  // 引入评论组件
  import comment from '../subcom/comment.vue';

  export default {
    data() {
      return {
        info: {}
      }
    },
    components: {
      comment  // 注册评论组件
    },
    methods: {
      getnews(){
        // var url = 'http://182.254.146.100:8899/api/getnew/'+this.$route.params.newsid;
        var url = common.apidomain + '/api/getnew/'+this.$route.params.newsid;
        this.$http.get(url)
                  .then(function(res){
                    if(res.body.status != 0){
                      alert(res.body.message);
                      return;
                    }
                    this.info = res.body.message[0];
                  });
      }
    },
    created(){
      this.getnews();
    }
  }
</script>

<style scoped>
  .title h4 {
    color: #26a2ff;
  }
  .content {
    padding: 5px;
  }
</style>
